import { defineStore } from 'pinia'
import { store } from '/@/store'
import type { AxiosResponse } from 'axios'
import type { Res } from '/@/tool/Res'
import type { Param } from '/@/tool/Param'

import dbTableConfService from '/@/api/cn/core/coding/dbTableConfService'

import type { DbTableConf } from '/@/model/cn/core/coding/eo/DbTableConf'
import type { DbTableConfQO } from '/@/model/cn/core/coding/qo/DbTableConfQO'
import type { DbTableConfVO } from '/@/model/cn/core/coding/vo/DbTableConfVO'

interface DbTableConfState {
}

export const useDbTableConfStore = defineStore({
  id: 'dbTableConf',
  state: (): DbTableConfState => ({
  }),
  getters: {
  },
  actions: {
    save(param: Param<DbTableConf>): Promise<Res<DbTableConf>> {
      return new Promise<Res<DbTableConf>>((resolve, reject) => {
        dbTableConfService.save(param).then((res: AxiosResponse<Res<DbTableConf>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    saveBatch(param: Param<DbTableConf>): Promise<Res<DbTableConf>> {
      return new Promise<Res<DbTableConf>>((resolve, reject) => {
        dbTableConfService.saveBatch(param).then((res: AxiosResponse<Res<DbTableConf>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    update(param: Param<DbTableConf>): Promise<Res<DbTableConf>> {
      return new Promise<Res<DbTableConf>>((resolve, reject) => {
        dbTableConfService.update(param).then((res: AxiosResponse<Res<DbTableConf>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    updateBatch(param: Param<DbTableConf>): Promise<Res<DbTableConf>> {
      return new Promise<Res<DbTableConf>>((resolve, reject) => {
        dbTableConfService.updateBatch(param).then((res: AxiosResponse<Res<DbTableConf>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    remove(param: Param<DbTableConf>): Promise<Res<DbTableConf>> {
      return new Promise<Res<DbTableConf>>((resolve, reject) => {
        dbTableConfService.remove(param).then((res: AxiosResponse<Res<DbTableConf>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    removeBatch(param: Param<DbTableConf>): Promise<Res<DbTableConf>> {
      return new Promise<Res<DbTableConf>>((resolve, reject) => {
        dbTableConfService.removeBatch(param).then((res: AxiosResponse<Res<DbTableConf>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    count(param: Param<DbTableConfQO>): Promise<Res<DbTableConf>> {
      return new Promise<Res<DbTableConf>>((resolve, reject) => {
        dbTableConfService.count(param).then((res: AxiosResponse<Res<DbTableConf>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    pk(param: Param<DbTableConfQO>): Promise<Res<DbTableConf>> {
      return new Promise<Res<DbTableConf>>((resolve, reject) => {
        dbTableConfService.pk(param).then((res: AxiosResponse<Res<DbTableConf>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    query(param: Param<DbTableConfQO>): Promise<Res<DbTableConf>> {
      return new Promise<Res<DbTableConf>>((resolve, reject) => {
        dbTableConfService.query(param).then((res: AxiosResponse<Res<DbTableConf>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    paging(param: Param<DbTableConfQO>): Promise<Res<DbTableConf>> {
      return new Promise<Res<DbTableConf>>((resolve, reject) => {
        dbTableConfService.paging(param).then((res: AxiosResponse<Res<DbTableConf>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    countVo(param: Param<DbTableConfQO>): Promise<Res<DbTableConfVO>> {
      return new Promise<Res<DbTableConfVO>>((resolve, reject) => {
        dbTableConfService.countVo(param).then((res: AxiosResponse<Res<DbTableConfVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    pkVo(param: Param<DbTableConfQO>): Promise<Res<DbTableConfVO>> {
      return new Promise<Res<DbTableConfVO>>((resolve, reject) => {
        dbTableConfService.pkVo(param).then((res: AxiosResponse<Res<DbTableConfVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    queryVo(param: Param<DbTableConfQO>): Promise<Res<DbTableConfVO>> {
      return new Promise<Res<DbTableConfVO>>((resolve, reject) => {
        dbTableConfService.queryVo(param).then((res: AxiosResponse<Res<DbTableConfVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    pagingVo(param: Param<DbTableConfQO>): Promise<Res<DbTableConfVO>> {
      return new Promise<Res<DbTableConfVO>>((resolve, reject) => {
        dbTableConfService.pagingVo(param).then((res: AxiosResponse<Res<DbTableConfVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
  },
})

export function useDbTableConfStoreWithout() {
  return useDbTableConfStore(store)
}
